# -*- coding: utf-8 -*-
import scrapy
from scrapy_redis.spiders import RedisSpider


class DangdangSpider(RedisSpider):
    name = 'dangdang'
    allowed_domains = ['dangdang.com']
    # start_urls = ['http://dangdang.com/']

    def parse(self, response):
        #大分类分组
        div_list = response.xpath("//div[@class='con flq_body']/div")
        for div in div_list:
            item = {}
            #获取大分类的名字
            item["b_title"] = div.xpath("./dl/dt//text()").extract()
            item["b_title"] = [i.strip() for i in item["b_title"] if len(i.strip()) > 0]